﻿@model SpamModel
@{
    ViewBag.Title = "Checked";
}

<h2>Checked</h2>

<p>The checked binding links a checkable form control — i.e., a checkbox (&lt;input type="checkbox"&gt;) or a radio button (&lt;input type="radio"&gt;) — with a property on your view model.</p>
<p><a href="http://knockoutjs.com/documentation/checked-binding.html" target="_blank">http://knockoutjs.com/documentation/checked-binding.html</a></p>

@Html.VisiTogglerFromPartial(CodeSamplePartials.CHECKED_VIEW_MODEL, Html.CreateVisiToggler("show the samples view model C# source code ", htmlAttributes: new { @class = "onright" }, options: VisiOptions.HiddenByDefault))
<br />
@Html.VisiTogglerFromPartial(CodeSamplePartials.CHECKED_CONTROLLER, Html.CreateVisiToggler("show the samples controller C# source code ", htmlAttributes: new { @class = "onright" }, options: VisiOptions.HiddenByDefault))


<h3>Sample #1</h3>

<p><label for="cb1">Send me spam: </label> <input id="cb1" type="checkbox" @Html.KoAttrChecked(m => m.WantsSpam) /></p>

<p>Want to get spam: @Html.KoText(m => m.WantsSpam)</p>

@Html.VisiTogglerFromPartial(CodeSamplePartials.CHECKED1, Html.CreateVisiToggler("show the sample source code ", htmlAttributes: new { @class = "onright" }, options: VisiOptions.HiddenByDefault))

<h3>Sample #2</h3>

<div @Html.KoAttrVisible(m => m.WantsSpam)>
    Preferred flavors of spam:
    <div><input type="checkbox" value="cherry" @Html.KoAttrChecked(m => m.SpamFlavors) /> Cherry</div>
    <div><input type="checkbox" value="almond" @Html.KoAttrChecked(m => m.SpamFlavors) /> Almond</div>
    <div><input type="checkbox" value="msg" @Html.KoAttrChecked(m => m.SpamFlavors) /> Monosodium Glutamate</div>

<p>Spam flavours: @Html.KoText(m => m.SpamFlavors)</p>

</div>

@Html.VisiTogglerFromPartial(CodeSamplePartials.CHECKED2, Html.CreateVisiToggler("show the sample source code ", htmlAttributes: new { @class = "onright" }, options: VisiOptions.HiddenByDefault))

<h3>Sample #3</h3>

<div @Html.KoAttrVisible(m => m.WantsSpam)>
    Send me spam:

    <div><input type="radio" name="flavorGroup" value="cherry" @Html.KoAttrChecked(m => m.SpamFlavor) /> Cherry</div>
    <div><input type="radio" name="flavorGroup" value="almond" @Html.KoAttrChecked(m => m.SpamFlavor) /> Almond</div>
    <div><input type="radio" name="flavorGroup" value="msg" @Html.KoAttrChecked(m => m.SpamFlavor) /> Monosodium Glutamate</div>

    <p>Spam flavour: @Html.KoText(m => m.SpamFlavor)</p>

</div>

@Html.VisiTogglerFromPartial(CodeSamplePartials.CHECKED3, Html.CreateVisiToggler("show the sample source code ", htmlAttributes: new { @class = "onright" }, options: VisiOptions.HiddenByDefault))

<p>&nbsp;</p>
<p>Next &gt; @Html.ActionLink("Options", "Options", "Examples")</p>

@Model.ApplyBindingsScript(KoBindingOptions.IncludeData)